100 research outputs found

    Bidirectionalization for Free with Runtime Recording: Or, a Light-Weight Approach to the View-Update Problem

    Get PDF
    A bidirectional transformation is a pair of mappings between source and view data objects, one in each direction. When the view is modified, the source is updated accordingly with respect to some laws. Over the years, a lot of effort has been made to offer better language support for programming such transformations. In particular, a technique known as bidirectionalization is able to analyze and transform unidirectional programs written in general purpose languages, and "bidirectionalize" them. Among others, a technique termed as semantic bidirectionalization proposed by Voigtländer stands out in term of user-friendliness. The unidirectional program can be written using arbitrary language constructs, as long as the function is polymorphic and the language constructs respect parametricity. The free theorems that follow from the polymorphic type of the program allow a kind of forensic examination of the transformation, determining its effect without examining its implementation. This is convenient, in the sense that the programmer is not restricted to using a particular syntax; but it does require the transformation to be polymorphic. In this paper, we lift this polymorphism requirement to improve the applicability of semantic bidirectionalization. Concretely, we provide a type class PackM γ α μ, which intuitively reads "a concrete datatype γ is abstracted to a type α, and the 'observations' made by a transformation on values of type γ are recorded by a monad μ". With PackM, we turn monomorphic transformations into polymorphic ones, that are ready to be bidirectionalized. We demonstrate our technique with a case study of standard XML queries, which were considered beyond semantic bidirectionalization because of their monomorphic nature

    Modular Inference of Linear Types for Multiplicity-Annotated Arrows

    Full text link
    Bernardy et al. [2018] proposed a linear type system λq\lambda^q_\to as a core type system of Linear Haskell. In the system, linearity is represented by annotated arrow types AmBA \to_m B, where mm denotes the multiplicity of the argument. Thanks to this representation, existing non-linear code typechecks as it is, and newly written linear code can be used with existing non-linear code in many cases. However, little is known about the type inference of λq\lambda^q_\to. Although the Linear Haskell implementation is equipped with type inference, its algorithm has not been formalized, and the implementation often fails to infer principal types, especially for higher-order functions. In this paper, based on OutsideIn(X) [Vytiniotis et al., 2011], we propose an inference system for a rank 1 qualified-typed variant of λq\lambda^q_\to, which infers principal types. A technical challenge in this new setting is to deal with ambiguous types inferred by naive qualified typing. We address this ambiguity issue through quantifier elimination and demonstrate the effectiveness of the approach with examples.Comment: The full version of our paper to appear in ESOP 202

    Refactoring pattern matching

    Get PDF
    Defining functions by pattern matching over the arguments is advantageous for understanding and reasoning, but it tends to expose the implementation of a datatype. Significant effort has been invested in tackling this loss of modularity; however, decoupling patterns from concrete representations while maintaining soundness of reasoning has been a challenge. Inspired by the development of invertible programming, we propose an approach to program refactoring based on a right-invertible language rinv—every function has a right (or pre-) inverse. We show how this new design is able to permit a smooth incremental transition from programs with algebraic datatypes and pattern matching, to ones with proper encapsulation, while maintaining simple and sound reasoning

    Sparcl:A Language for Partially-Invertible Computation

    Get PDF

    Numerical Simulation of the Surface Flow on the Companion Star in a Close Binary System II. Construction of Doppler maps and application to Galactic supersoft X-ray sources

    Full text link
    We perform three-dimensional numerical simulations of surface flows on the companion star in a semi-detached binary system and construct the corresponding Doppler maps. The mass ratio of the binary system, q=M2/M1q=M_2/M_1, considered here is q=0.05,0.33,0.5,1,2q=0.05, 0.33, 0.5, 1, 2, and 3. For all cases, we obtain the H-, L1-, and L2-eddies, as found in our previous work, and confirm that the flow pattern does not heavily depend on the mass ratio. We propose that this kind of problem be dubbed ``{\it stellar meteorology}.'' The Doppler maps at the position of the companion show a structure tilted towards clockwise direction and presenting deviations from the critical Roche surface due to the L1-eddy and the L2-eddy on the companion star. We apply our results to the Galactic supersoft X-ray source RX J0019.8+2156 and try to attribute the low radial velocity component of the emission lines of He II λ4686{\lambda}4686 observed recently to the irradiated spot on the surface of the companion rather than that of the white dwarf or the accretion disc. Based on the comparison between the observations and our constructed Doppler map, we estimate the mass of the companion star in RX J0019.8+2156 to be 2M\sim 2 M_{\odot} assuming the mass of the white dwarf star to be around 0.6M0.6 M_{\odot}.Comment: 8 pages, 9 figures, Accepted for publication in A&

    Combining Syntactic and Semantic Bidirectionalization

    Get PDF
    Matsuda et al. [2007, ICFP] and Voigtlander [2009, POPL] introduced two techniques that given a source-to-view function provide an update propagation function mapping an original source and an updated view back to an updated source, subject to standard consistency conditions. Being fundamentally different in approach, both techniques have their respective strengths and weaknesses. Here we develop a synthesis of the two techniques to good effect. On the intersection of their applicability domains we achieve more than what a simple union of applying the techniques side by side deliver

    Enhancing Semantic Bidirectionalization via Shape Bidirectionalizer Plug-ins

    Get PDF
    Matsuda et al. (2007) and Voigtlander (2009) have introduced two techniques that given a source-to-view function provide an update propagation function mapping an original source and an updated view back to an updated source, subject to standard consistency conditions. Previously, we developed a synthesis of the two techniques, based on a separation of shape and content aspects (Voigtlander et al. 2010). Here, we carry that idea further, reworking the technique of Voigtlander such that any shape bidirectionalizer (based on the work of Matsuda et al. or not) can be used as a plug-in, to good effect. We also provide a data-type-generic account, enabling wider reuse, including the use of pluggable bidirectionalization itself as a plug-in

    Synbit:Synthesizing Bidirectional Programs using Unidirectional Sketches

    Get PDF

    FliPpr:A System for Deriving Parsers from Pretty-Printers

    Get PDF
    corecore